package com.example.demo2database.m;


import com.sun.istack.Nullable;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface DormRepository extends CrudRepository<Dorm,Integer> {
    /*
        统计楼栋数
        SELECT COUNT(DISTINCT column_name) FROM table_name
        SELECT COUNT(DISTINCT b_num) FROM dorm
     */

    @Nullable
    @Query(value = "SELECT COUNT(DISTINCT bnum) FROM Dorm  ")
    String countBNums();
    @Nullable
    @Query(value = "SELECT bnum,rnum FROM Dorm",nativeQuery=true)
    List<String> printBNums();
    @Nullable
    @Query(value = "SELECT COUNT(DISTINCT rnum ) FROM Dorm ")
    public String countrNums();
}
